package com.school_admin.config;

import com.school_admin.interceptor.JwtValidateInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 拦截器配配置类
@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private JwtValidateInterceptor jwtValidateInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(jwtValidateInterceptor);
        registration.addPathPatterns("/**")
                .excludePathPatterns(
                        "/upload",
                        "/image/**",
                        "/user/login",
                        "/post/getNewList",
                        "/post/getPageListWeb",
                        "/post/getSearchList",
                        "/post/find/**",
                        "/post/updateViewCount/**",
                        "/comment/getComment/**",
                        "/user/add",
                        "/category/getCategoryParentId",
                        "/category/list",
                        "/category/find/**",
                        "/user/logout",
                        "/admin/login",
                        "/feedback/list",
                        "/static/**",
                        "/video/upload",
                        "/post/getLabel",
                        "/swiper/web/list"
                );
    }

//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/static/**")
//                //2、添加了资源处理器路径后对应的映射资源路径
//                .addResourceLocations("classpath:/static/");
//    }
}
